<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript更改属性</title>
</head>
<body>
<script>
  function myFunction(pd) {
    var picture;
    if (pd == 0) {
      picture = "../eg_bulboff.jpg"
    } else {
      picture = "../eg_bulbon.jpg"
    }
    document.getElementById("image").src=picture
  }
</script>

<img id="image" src="../../eg_bulboff.jpg" width="109" height="180"/>
<br/>
<button type="button" onclick="myFunction(0)">关</button>
<button type="button" onclick="myFunction(1)">开</button>
</body>
</html>